<template>
  <div class="pager-wrapper">
    <el-pagination
      :page-sizes="[10, 20, 30, 50]"
      :page-size="pagesize"
      :total="total"
      v-model:current-page="currentPage"
      layout="total, sizes, prev, pager, next, jumper"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
    />
  </div>
</template>

<script>
import { ref } from "vue"
export default {
  props: {
    total: {
      type: Number,
      default: 0
    }
  },

  setup(props, context) {
    const pagesize = ref(10),
      currentPage = ref(1)
    const handleSizeChange = (val) => {
      pagesize.value = val
      context.emit("sizeChange", val)
    }
    const handleCurrentChange = (val) => {
      currentPage.value = val
      context.emit("currentChange", val)
    }
    return {
      currentPage,
      handleCurrentChange,
      pagesize,
      handleSizeChange
    }
  }
}
</script>
